package cj.web.marriageSC.dao;
/*
 *  
 *  
*/
import java.util.List;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.ReturnGeneratedKeys;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.marriageSC.domain.SCBuyer;

/**
 * 
 * @author 
 *
 */
@DAO
public interface SCBuyerDAO{
	
	@ReturnGeneratedKeys
	@SQL("INSERT INTO SCBuyer (id,phone,name,deleteFlag,createUser,createAt,updateUser,updateAt) VALUES (:t.id,:t.phone,:t.name,1,:t.createUser,now(),:t.updateUser,now())")
	public int create(@SQLParam("t") SCBuyer sCBuyer);
	
    @SQL("select * from SCBuyer where id=:1")
    SCBuyer queryById(int id);
    
    @SQL("SELECT * FROM SCBuyer WHERE deleteFlag=1 AND phone=:1")
    List<SCBuyer> queryByPhone(String phone);
    
	@SQL("UPDATE SCBuyer SET phone=:t.phone,name=:t.name,updateUser=:t.updateUser,updateAt=NOW() WHERE id=:t.id")
    void update(@SQLParam("t") SCBuyer sCBuyer);
    
    @SQL("UPDATE SCBuyer SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);

    @SQL("select * from SCBuyer WHERE deleteFlag=1 #if(:t.phone!=''){ and phone like '%##(:t.phone)%' } order by createAt desc limit :t.start,:t.length")
	List<SCBuyer> queryByPhone(@SQLParam("t")SCBuyer buyer);

    @SQL("select count(0) from SCBuyer WHERE deleteFlag=1 #if(:t.phone!=''){ and phone like '%##(:t.phone)%' }")
	int sizeByPhone(@SQLParam("t")SCBuyer buyer);
}